package com.wx.datastructure.stack.linked;


import com.wx.datastructure.linked.BothwayLinkedList;
import com.wx.datastructure.stack.Stack;

/**
 * @author wx
 * @Description: 线性数据结构-双向链表类型-栈(先进后出)
 * @date 2018/12/18 001818:24
 */
public class LinkedStack<E> implements Stack<E> {

    private BothwayLinkedList<E> bothwayLinkedList = new BothwayLinkedList<>();


    @Override
    public int size() {
        return bothwayLinkedList.getSize();
    }

    @Override
    public boolean isEmpty() {
        return bothwayLinkedList.isEmpty();
    }

    @Override
    public void push(E e) {
        bothwayLinkedList.addFirst(e);
    }

    @Override
    public E pop() {
        return bothwayLinkedList.removeFirst();
    }

    @Override
    public E peek() {
        return bothwayLinkedList.getFirst();
    }
}
